Skip to content

fix: load Yarn catalogs from .yarnrc.yml (#148)#149

Merged
theoephraim merged 2 commits into
mainfrom
fix/yarn-catalogs-yarnrc-148
Jul 3, 2026
Merged

fix: load Yarn catalogs from .yarnrc.yml (#148)#149
theoephraim merged 2 commits into
mainfrom
fix/yarn-catalogs-yarnrc-148

Conversation

@theoephraim

Copy link
Copy Markdown
Member

Fixes #148.

Problem

Yarn (>=4.10) defines catalogs in .yarnrc.yml under the catalog / catalogs keys, with package.json only referencing them via the catalog: protocol. Catalog loading only read pnpm-workspace.yaml (pnpm) and package.json (bun/npm), so in a Yarn workspace the catalog map always came back empty — breaking catalog: protocol resolution at publish time and catalog-driven change detection.

Fix

Yarn's .yarnrc.yml uses the exact same catalog / catalogs shape as pnpm's pnpm-workspace.yaml, so no new parsing is needed — the loader just has to read the right file for the detected package manager.

  • Add a catalogYamlFile(pm) helper: pnpmpnpm-workspace.yaml, yarn.yarnrc.yml, npm/bun → none (they use package.json).
  • loadCatalogs and the check command's catalog diff now consult that file instead of hardcoding pnpm.
  • Add .yarnrc.yml to CATALOG_FILES so bumpy check detects catalog changes in Yarn repos.
  • Rename parseCatalogs's first param pnpmWorkspaceYamlworkspaceYaml (it's format-agnostic).

Because every downstream consumer (dependency propagation, catalog: resolution during publish) reads the resulting CatalogMap, fixing the load path fixes the whole flow.

Tests

Added coverage in package-manager.test.ts: parsing Yarn's .yarnrc.yml shape, the catalogYamlFile helper, and an integration test that detectWorkspaces loads catalogs from .yarnrc.yml for a Yarn repo (and ignores a stray .yarnrc.yml in a pnpm repo).

Full suite passes (318 tests), plus tsc and lint are clean.

Yarn (>=4.10) stores catalog definitions in .yarnrc.yml under the
catalog/catalogs keys, the same shape pnpm uses in pnpm-workspace.yaml.
Catalog loading only read pnpm-workspace.yaml and package.json, so Yarn
workspaces always got an empty catalog map.

Add a catalogYamlFile(pm) helper (pnpm -> pnpm-workspace.yaml,
yarn -> .yarnrc.yml) and use it in both loadCatalogs and check's
catalog-diff, and include .yarnrc.yml in CATALOG_FILES.
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

bumpy-frog

The changes in this PR will be included in the next version bump.

patch Patch releases

  • @varlock/bumpy 1.18.0 → 1.18.1

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

@theoephraim theoephraim merged commit 4960ffc into main Jul 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Yarn catalogs are defined in .yarnrc.yml, but catalog loading only reads pnpm-workspace.yaml and package.json

1 participant